<?php
	if ( ! isset( $content_width ) ) $content_width = 630;
	/* Set up theme defaults and registers support for various WordPress features. */
	if ( ! function_exists( 'dt_init' ) ){
	
		function include_files_in_dir($dir, $no_more=FALSE){
		  $dir_init = $dir;
		  $dir = dirname(__FILE__).$dir;
		  
		  if (!file_exists($dir))
			 throw new Exception("Folder $dir does not exist");
			 
		  $files = array();
			 
		  if ($handle = opendir( $dir )) {
			  while (false !== ($file = @readdir($handle))) {
				  if ( is_dir( $dir.$file ) && !preg_match('/^\./', $file) && !$no_more )
				  {
					 include_files_in_dir($dir_init.$file."/", TRUE);
				  }
				  else
				  {
					 if ( preg_match('/^[^~]{1}.*\.php$/', $file) ) {
						 $files[] = $dir.$file;
					 }
				  }
			  }
			  @closedir($handle);
		  }      
		  
		  sort($files);
		  
		  foreach ($files as $file)
			 include_once $file;
		}

		function dt_init(){
					
			/* menu slot */
			//global $dt_post_formats;
			//$dt_post_formats = array( 'gallery', 'status' );
			register_nav_menu( 'primary-menu', __( 'Primary Menu', 'dt' ) );
			//add_theme_support( 'post-formats', $dt_post_formats );
			
			if ( function_exists( 'add_theme_support' ) ) { 
				/* add theme support images */
				add_theme_support( 'post-thumbnails' );
				/* add automatic feeds support */
				add_theme_support( 'automatic-feed-links' );				
			}
						
			// Include functions/*.php
			include_files_in_dir("/functions/");
			
			// Include plugins/*/*.php
			include_files_in_dir("/plugins/", true);
            include_files_in_dir("/plugins/options-framework/", true);
            include_files_in_dir("/plugins/shortcodekid/", true);
            
			
			// for translate purpose
			if( function_exists( 'load_theme_textdomain' ) ){
				load_theme_textdomain( LANGUAGE_ZONE, get_template_directory(). '/language' );
			}
			
			//remove in production , for demo stand only!!!
			if( function_exists( 'optionsframework_dt_presets' ) ){
				optionsframework_dt_presets();
			}
		}
	}
	//add_action( 'init', 'dt_init' );
	add_action( 'after_setup_theme', 'dt_init' );
?>